package com.emm.yixun.mobile.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.model.GetBuildingList.BuildingList;

public class SelectbuildingAdapter extends BaseAdapter {

	Context context;

	ArrayList<BuildingList> name;

	public SelectbuildingAdapter(Context context, ArrayList<BuildingList> name) {
		this.context = context;
		this.name = name;
	}

	public void GetDate(ArrayList<BuildingList> name) {
		this.name = name;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return name == null ? 0 : name.size();
	}

	@Override
	public Object getItem(int position) {
		return name == null ? null : name.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHd v = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.spinner_item, null);
			v = new ViewHd();
			v.spinner_name = (TextView) convertView.findViewById(R.id.spinner_name);
			convertView.setTag(v);
		} else {
			v = (ViewHd) convertView.getTag();
		}
		v.spinner_name.setText(name.get(position).getBuildingName());
		return convertView;
	}

	public static class ViewHd {
		TextView spinner_name;
	}

}
